package AccionBoton;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;

import javax.swing.JComboBox;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;

import modelUtil.Configuracion;
import modelUtil.Util;
import paginas.MenuConfigBarridoTab;
import paginas.MenuConfigIdiomaTab;
import paginas.MenuConfigPasswordTab;

public class AccionMenuConfig implements ActionListener{

	private JTabbedPane _panel;
	
	public AccionMenuConfig(JTabbedPane panel){
		
		_panel = panel;
		
	}
	
	public void actionPerformed(ActionEvent evt){
	
			MenuConfigPasswordTab _tab1;
			MenuConfigIdiomaTab _tab2;
			MenuConfigBarridoTab _tab3;
			
			_tab1 = (MenuConfigPasswordTab)_panel.getComponent(0);
			JTextField t1 = _tab1.getTexto1();
			JTextField t2 = _tab1.getTexto2();
		
			_tab2 = (MenuConfigIdiomaTab)_panel.getComponent(1);
			if(_tab2.getBoton1().isSelected())Locale.setDefault(new Locale("es","ES"));
			if(_tab2.getBoton2().isSelected())Locale.setDefault(new Locale("en","UK"));
			if(_tab2.getBoton3().isSelected())Locale.setDefault(new Locale("gl","ES"));
					
			_tab3 = (MenuConfigBarridoTab)_panel.getComponent(2);	
			if(_tab3.getBoton1().isSelected()){	
				Configuracion.instancia().setBarrido("No");
			}
		
			if(_tab3.getBoton2().isSelected()){
				
				Configuracion.instancia().setBarrido("Si");
				JComboBox caja = _tab3.getDesplegable();
				Configuracion.instancia().setTiempoBarrido(caja.getSelectedItem().toString());
				
			}
				
	}
	
	
}
